
<template>
  <div class="common-layout">
    <el-container>
      <el-header class="custom-header">
        <div class="header-content">
          <div class="logo">后台管理系统</div>
          <div class="user-info">
            <span>欢迎您，咨询师：{{ adminName }}</span>
            <el-button @click="logout" type="text">退出登录</el-button>
          </div>
        </div>
      </el-header>
      <el-container>
        <el-aside class="sidebar">
          <el-menu default-active="2" class="el-menu-vertical-demo" router>
            <el-menu-item index="pcinfo" v-if="userPower === '2'"
              >咨询师</el-menu-item
            >
            <el-menu-item index="pcyuyue" v-if="userPower === '2'"
              >预约列表</el-menu-item
            >
            <el-menu-item index="workschedule" v-if="userPower === '2'"
              >咨询师个人排班</el-menu-item
            >
          </el-menu>
        </el-aside>
        <el-main class="main-content">
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      adminName: "",
      routerList: [],
      userPower: localStorage.getItem("userPower"),
    };
  },
  mounted() {
    this.adminName = localStorage.getItem("adminName");
    this.routerList = this.$router.getRoutes();
    this.routerList = this.routerList.filter(
      (item) => item.meta.power == this.userPower
    );
  },
  methods: {
    logout() {
      localStorage.removeItem("adminName");
      localStorage.removeItem("token");
      localStorage.removeItem("userPower");
      this.$router.push("/");
    },
  },
};
</script>

<style >
.el-aside {
  background-color: #eee;
  height: 100vh;
  width: auto;
}
.el-menu {
  width: 200px;
  background-color: #eee;
}
.common-layout {
  font-family: "Arial", sans-serif;
}

.custom-header {
  background-color: #f8f8f7;
  color: #333;
  border-bottom: 1px solid #d2d2d7;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
}

.logo {
  font-size: 1.8em;
  font-weight: bold;
  color: #333;
}

.user-info {
  display: flex;
  align-items: center;
  font-size: 0.9em;
}

.user-info span {
  margin-right: 10px;
  color: #666;
}

.el-button {
  color: #007aff;
}

.sidebar {
  background-color: #fafafa;
  border-right: 1px solid #d2d2d7;
}

.el-menu-vertical-demo {
  background-color: black(219, 214, 214, 0.292);
}

.el-menu-item {
  color: #333333;
}

.el-menu-item:hover {
  background-color: #f0f0f5;
}

.main-content {
  padding: 20px;
  background-color: #fff;
}
</style>